﻿@{
    ViewBag.Title = "寄件信息";
    var provinceList = ServiceFactory.D_ProvinceServiceInstance.GetDProvinceAll();
    var selectList = new SelectList(provinceList, "ProvinceID", "ProvinceName");
}

@using ZBJF.Warranty.BLL
@using ZBJF.Warranty.Common.Enums.InsuranceWarranty
@using ZBJF.Warranty.WebProvider
@model ZBJF.Warranty.Model.InsuranceWarrantyRecord
@using (Html.BeginForm("SaveSendBackInfo", "InsuranceWarrantyRecord", FormMethod.Post, new { id = "mvcForm", name = "mvcForm", @class = "form-horizontal", enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    @Html.HiddenFor(c => c.ID)
    @Html.HiddenFor(c => c.InsuranceOrderId)
    <h4>收件信息</h4>
    if (ViewBag.ParentStatus != (byte)InsuranceWarrantyStatus.Processed && Model.Status != (byte)InsuranceWarrantyStatus.RetrurnVisited)
    {
        <table class="table table-responsive table-bordered table-hover">
            <tr>
                <th class="w120">快递公司：</th>
                <td>@Html.DropDownListFor(m => m.SendBackExpress, ConvertToSelector.Instance.EnumTypeConvertToSelectList(typeof(ExpressEnums), addEmptySelect: false))</td>

            </tr>
            <tr>
                <th class="w120">快递单号：</th>
                <td>@Html.TextBoxFor(m => m.SendBackExpressNo, new { validate = "{required:true,messages:{required:'快递单号必填！'}}", @class = "w-p95" })</td>
            </tr>
            <tr>
                <th>收件人：</th>
                <td>@Html.TextBoxFor(m => m.SendBackToUserName, new { validate = "{required:true,messages:{required:'收件人必填！'}}", @class = "w-p95" })</td>
            </tr>
            <tr>
                <th>收件人手机：</th>
                <td>@Html.TextBoxFor(m => m.SendBackToUserPhone, new { validate = "{required:true,isTel:true,messages:{required:'收件人手机必填！'}}", @class = "w-p95" })</td>
            </tr>
            <tr>
                <th>收件人地址：</th>
                <td>@Html.DropDownListFor(m => m.SendBackToProvinceId, selectList, new { title = "请先选择省份" })@Html.DropDownListFor(m => m.SendBackToCityId, new List<SelectListItem>(), new { title = "请选择城市" })</td>
            </tr>
            <tr>
                <th>详细地址：</th>
                <td>@Html.TextBoxFor(m => m.SendBackToAddress, new { validate = "{required:true,messages:{required:'详细地址必填！'}}", @class = "w-p95" })</td>
            </tr>
            <tr>
                <th>寄件人：</th>
                <td>
                    @Html.TextBoxFor(m => m.SendBackUserName, new { validate = "{required:true,messages:{required:'寄件人必填！'}}", @class = "w-p95" })
                </td>
            </tr>
            <tr>
                <th>寄件时间：</th>
                <td>
                    @Html.TextBoxFor(m => m.SendBackTime, new { Value = !Model.SendBackTime.HasValue ? string.Empty : Model.SendBackTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), validate = "{required:true,messages:{required:'寄件时间必填！'}}", onclick = "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})", @class = "Wdate" })
                </td>
            </tr>
        </table>
        <div class="form-actions center">
            <input id="btnAuditAndPass" class="btn btn-primary Edit-R" type="submit" value="提交">
            <input id="btnCancel" class="btn btn-primary Edit-R" type="button" value="取消">
        </div>
    }
    else
    {
        <table class="table table-responsive table-bordered table-hover">
            <tr>
                <th class="w120">快递公司：</th>
                <td>@ZBJF.Warranty.Common.Common.EnumHelper.Instance.GetDescription(typeof(ExpressEnums), Model.SendBackExpress)</td>

            </tr>
            <tr>
                <th class="w120">快递单号：</th>
                <td>@Model.SendBackExpressNo</td>
            </tr>
            <tr>
                <th>收件人：</th>
                <td>@Model.SendBackToUserName</td>
            </tr>
            <tr>
                <th>收件人手机：</th>
                <td>@Model.SendBackToUserPhone</td>
            </tr>
            <tr>
                <th>收件人地址：</th>
                <td>
                    @(Model.D_Province1 != null ? Model.D_Province1.ProvinceName : string.Empty) @(Model.D_City1 != null ? Model.D_City1.CityName : string.Empty)
                </td>
            </tr>
            <tr>
                <th>详细地址：</th>
                <td>@Model.SendBackToAddress</td>
            </tr>
            <tr>
                <th>寄件人：</th>
                <td>@Model.SendBackUserName</td>
            </tr>
            <tr>
                <th>寄件时间：</th>
                <td>@Model.SendBackTime</td>
            </tr>
        </table>
    }
}

@section scripts
{
    <script type="text/javascript">
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        $(document).ready(function() {
            //关闭iframe
            $('#btnCancel').click(function () {
                parent.layer.close(index);
            });
        });
        $(function () {
            provinceChange();
            $("#SendBackToProvinceId").change(function () {
                provinceChange();
            });
        });
        function provinceChange() {
            var provinceID = $("#SendBackToProvinceId").val();
            $.ajax({
                url: "/Common/GetCityList?provinceID=" + provinceID,
                success: function (data) {
                    var html = "";
                    if (data && data.length > 0) {
                        for (var i = 0; i < data.length; i++) {
                            html += "<option value='";
                            html += data[i].Value;
                            html += "'>" + data[i].Text;
                            html += "</option>";
                        }
                        $("#SendBackToCityId").html(html);
                    }
                }
            });
        }
    </script>
}